//
//  HXTopTitleView.m
//  爱鲜蜂
//
//  Created by 洪东恒 on 16/5/8.
//  Copyright © 2016年 建国. All rights reserved.
//

#import "HXTopTitleView.h"
#import "HXLocation.h"
#import <CoreLocation/CoreLocation.h>

@interface HXTopTitleView()<CLLocationManagerDelegate>

@property (weak, nonatomic) IBOutlet UILabel *titleView;

@property (nonatomic,strong) CLLocationManager *locationM;

@property (nonatomic,strong) CLGeocoder *geoc;

@end

@implementation HXTopTitleView

//快速构造方法
+(instancetype)topTitleView{
    
    return [[[NSBundle mainBundle]loadNibNamed:@"HXTopTitleView" owner:nil options:nil]firstObject];
}


- (IBAction)buttonClick {

    
}

-(void)awakeFromNib{
    
    HXLocation *location = [HXLocation sharedHXLocation];
    //获得地址信息
    NSString *add = location.address;
    if (add != nil) {
        
        self.titleView.text = add;
        NSLog(@"%@",add);
        
    }
}

////地理编码
//-(CLGeocoder *)geoc{
//    
//    if (_geoc ==nil ) {
//        
//        _geoc = [[CLGeocoder alloc]init];
//    }
//    
//    return _geoc;
//}
//
////调用代理方法
//-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
//    
//    // 1.获取用户的位置
//    CLLocation *location = locations.firstObject;
//    
//    if (location) {
//        return;
//    }
//    
//    // 2.判断位置是否可用
//    if (location.horizontalAccuracy < 0) {
//        return;
//    }
//    
//    // 3.获取经纬度,进行反地理编码
//    [self.geoc reverseGeocodeLocation:location completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
//        
//        // 1.获取地标对象
//        if (error == nil) {
//            NSArray *clpls = placemarks ;
//            if (clpls == nil ) {
//                return ;
//            }
//            
//            CLPlacemark *clpl = clpls.firstObject;
//            if (clpl == nil) {
//                return ;
//            }
//            
//            //获得地址
//            NSLog(@"%@",clpl.name);
//            
//        }
//
//    }];
//}


@end
